<template>
	<view class="tabs-container">


		
		<view>
			<view v-for="(item, index) in orderList" :key="index" class="blocks">
				<view class="block" @click="gotoDetails(item)">

					<view class="LeftDiv">
						<view class="SuoYingDiv">{{prefixZero(index+1,2)}}</view>
						<view class="TextDiv">
							<view class="Title">
								订单号：{{ item.orderNum }}
							</view>
							<view class="Title">
								支付方式：{{ item.payMethod==0?'微信':'支付宝' }}
							</view>
							<view class="time">
								{{ item.createTime }}
							</view>
							<view class="total">
								订单状态：
								<view class="OrderNumber" :style="item.OrderColor">
									{{ item.orderStatus }}
								</view>
							</view>
						</view>
					</view>

					<view class="RightDiv">
						$ {{ item.price}}
					</view>

				</view>
			</view>
		</view>
		
	</view>
</template>
<script>
	export default {
		data() {
			return {
				orderList: [], // 订单列表
				page: 1, // 页码
				pageSize: 10, // 页面大小
				noMore: false, // 没有更多了
				ColorStatus: new Map(),
				OrderColor: '',
				orderStatus: new Map(),
			};
		},
		onLoad() {
			this.orderStatus.set('0', '生成中');
			this.orderStatus.set('1', '已完成');
			this.orderStatus.set('2', '已取消');
			this.orderStatus.set('3', '已退款');

			this.ColorStatus.set('0', 'color:orange');
			this.ColorStatus.set('1', 'color:#25A785');
			this.ColorStatus.set('2', 'color:gray');
			this.ColorStatus.set('3', 'color:red');
			console.log(this.orderStatus.get('1'))
			this.OrderColor = this.ColorStatus.get('1')

			this.orderQueryByDate()
			// this.active = 0;
			// this.getAllOrderList(); // 获取订单
		},
		filters: {
			formatRule(val) {
				return val.replace(/\\n/g, '\n')
			}
		},
		
		methods: {
			orderQueryByDate() {
				let data = {
					storeId: wx.getStorageSync("SelectMenDian")
				}

				this.$request(this.$api.orderQueryByDate, data, "POST", false).then(res => {
					if (res.code == '0') {
						this.orderList = res.data
						this.orderList.forEach(i => {
							i.OrderColor = this.ColorStatus.get(i.orderStatus.toString())
							i.orderStatus = this.orderStatus.get(i.orderStatus.toString())
						})
					} else if (res.code == '40001') {

					} else {
						uni.showToast({
							title: res.description,
							icon: 'error'
						});
					}
				})
			},
			gotoDetails(item) {
				uni.navigateTo({
					url: "/pages/order/Details?orderNum=" + item.orderNum
				})
			},
			prefixZero(n, m) {
				var _a = (Array(m).join(0) + n).slice(-m);
				return _a;
			},
		},
	};
</script>
<style>
	.tabs-container {
		background-color: #f6f6f6;
		min-height: 100vh;
	}

	.OrderNumber {
		color: white;
		padding: 0 8rpx;
		display: flex;
		align-items: center;
	}

	.SuoYingDiv {
		width: 44rpx;
		height: 54rpx;
		margin: 0 42rpx;


		color: rgba(255, 195, 0, 1);
		font-size: 44rpx;
		text-align: left;
		font-weight: bold;
	}

	.total {
		color: rgba(69, 69, 83, 1);
		font-size: 22rpx;
		/* line-height: 120%; */
		text-align: center;
		/* margin-top: 8rpx; */
		display: flex;
		align-items: center;
		margin-top: 4rpx;
	}

	.blocks {
		margin-bottom: 0rpx;
	}

	.blocks .block {
		background: white;
		margin-top: 35rpx;
		padding-bottom: 32rpx;
		border-bottom: 1rpx solid rgba(238, 238, 238, 1);
	}

	.baccDiv {
		width: 10rpx;
		height: 100%;
		left: 14rpx;
		top: 142rpx;
		color: rgba(80, 80, 80, 1);
		background-color: rgba(73, 161, 255, 1);
		border-top-left-radius: 8rpx;
		border-bottom-left-radius: 8rpx;
		font-size: 24rpx;
		line-height: 150%;
		text-align: center;
	}

	.TextDiv {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		margin-left: 0rpx;
		gap: 4rpx;
	}

	.Title {
		letter-spacing: 2rpx;
		color: rgba(69, 69, 83, 1);
		font-size: 26rpx;
		line-height: 140%;
		text-align: left;
		margin-top: 8rpx;
	}

	.time {
		opacity: 0.5;
		letter-spacing: 2rpx;
		color: rgba(69, 69, 83, 1);
		font-size: 25rpx;
		line-height: 120%;
		text-align: left;
		margin: 8rpx 0;
	}

	.LeftDiv {
		height: 100%;
		display: flex;
		align-items: center;
	}

	.RightDiv {
		letter-spacing: 2rpx;
		color: rgba(212, 48, 48, 1);
		font-size: 34rpx;
		font-weight: 600;
		line-height: 120%;
		text-align: left;
		margin: 0 28rpx;
	}

	.blocks {
		display: flex;
		align-items: center;
		align-content: center;
		flex-direction: column;

	}

	.block {
		display: flex;
		align-items: center;
		align-content: center;
		justify-content: space-between;
		width: 100%;
		min-height: 132rpx;
		color: rgba(80, 80, 80, 1);
		background-color: rgba(255, 255, 255, 1);
		border-radius: 8rpx;
		overflow: hidden;
		font-size: 24rpx;
		line-height: 150%;
		text-align: center;
	}

	.order {
		display: flex;
		justify-content: space-between;
		background: white;
	}

	.active {
		color: rgb（255, 192, 0）;
		background-color: #ffc000;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.box {
		font-size: 30rpx;
		padding: 10rpx 10rpx;
		margin: 10rpx;
	}

	.sticky-top {
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		z-index: 1;
	}
</style>
